{include file="public/toper" /}
<style type="text/css">
    body{
        /*background: #eeeeee url() 0 0 no-repeat;*/
        background:url(/static/images/bg.png) no-repeat center;
        background-size: cover;
        overflow: hidden;
    }
    .captcha {
        position: absolute;
        right: 1px;
        top: 131px;
        border-left: 1px solid #e6e6e6;
        height: 48px;
    }
    .captcha img {
        height: 48px;
        cursor: pointer;
    }
</style>
<div class="login layui-anim layui-anim-up">
    <div class="message">商家平台-管理登录</div>
    <div id="darkbannerwrap"></div>

    <form class="layui-form" style="position: relative;">
        <input name="username" lay-verify="required" placeholder="用户名"  type="text"  autocomplete="off" class="layui-input" >
        <hr class="hr15">
        <input name="password" lay-verify="required" placeholder="密码"  type="password" autocomplete="off" class="layui-input">
        <hr class="hr15">

        <input name="captcha" lay-verify="required" placeholder="验证码" type="text" autocomplete="off" class="layui-input">
        <div class="captcha"><img src="{:captcha_src()}" alt="captche" title='点击切换' onclick="this.src='/captcha?id='+Math.random()"></div>
        <hr class="hr15">

        <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
        <hr class="hr20" >

    </form>
</div>

<script>
    layui.use('form',function(){
        var form = layui.form,$ = layui.jquery;

        //监听提交
        form.on('submit(login)', function(data){
            loading = layer.load(2, {
                shade: [0.2,'#000'] //0.2透明度的白色背景
            });
            var param = data.field;
            $.post('{:url("login/login")}',param,function(data){
                if(data.code == 200){
                    layer.close(loading);
                    layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                        location.href = '{:url("index/index")}';
                    });
                }else{
                    layer.close(loading);
                    layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
                    $('.captcha img').attr('src','/captcha?id='+Math.random());
                }
            });
            return false;
        });
    });
</script>
{include file="public/footer" /}